/*************************************************************************
 *                     COPYRIGHT NOTICE
 *            Copyright 2024 Horizon Robotics, Inc.
 *                   All rights reserved.
 *************************************************************************/
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "drm_utils.hpp"

uint32_t get_drm_property_id(int drm_fd, drmModeObjectProperties *props, const char *name)
{
	drmModePropertyPtr property;
	uint32_t i, id = 0;

	for (i = 0; i < props->count_props; i++) {
		property = drmModeGetProperty(drm_fd, props->props[i]);
		if (!strcmp(property->name, name)) {
			id = property->prop_id;
		}
		drmModeFreeProperty(property);

		if (id) {
			break;
		}
	}

	return id;
}